package com.nlscan.qdkit.ui.publico.util;

import android.view.View;

import com.google.android.material.snackbar.Snackbar;
import com.nlscan.qdkit.ui.publico.R;
import com.nlscan.qdkit.common.core.app.App;


/**
 * SnackBar 工具类
 */
public class SnackBarUtil {
    public static void Show(View view, String info) {
        Show(view, info, R.color.snackBarBackground, R.color.snackBarText, Snackbar.LENGTH_SHORT);
    }

    public static void ShowL(View view, String info) {
        Show(view, info, R.color.snackBarBackground, R.color.snackBarText, Snackbar.LENGTH_LONG);
    }

    public static void Show(View view, String info, int backgroundColorRes, int textColorRes, int duration) {
        Snackbar snackBar = Snackbar.make(view, info, duration);
        snackBar.getView().setBackgroundColor(App.getInstance().getResources().getColor(backgroundColorRes));
        snackBar.setActionTextColor(App.getInstance().getResources().getColor(textColorRes));
        snackBar.show();
    }

    public static Snackbar getNewInstance(View view, String info, int duration) {
        Snackbar snackBar = Snackbar.make(view, info, duration);
        snackBar.getView().setBackgroundColor(App.getInstance().getResources().getColor(R.color.snackBarBackground));
        snackBar.setActionTextColor(App.getInstance().getResources().getColor(R.color.snackBarText));
        return snackBar;
    }
}
